package com.ruoyi.web.controller.wq;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wq.domain.WqActivityUser;
import com.ruoyi.wq.service.IWqActivityUserService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 活动报名Controller
 * 
 * @author ruoyi
 * @date 2023-08-12
 */
@RestController
@RequestMapping("/wq/activityUser")
public class WqActivityUserController extends BaseController {

    @Autowired
    private IWqActivityUserService wqActivityUserService;

    /**
     * 查询活动列表
     */
    @GetMapping("/list")
    public TableDataInfo list(WqActivityUser wqActivityUser){
        TableDataInfo info = wqActivityUserService.getPageList(wqActivityUser);
        return info;
    }
    
    /**
     * 查询活动列表
     */
    @GetMapping("/getListByActivityId")
    public TableDataInfo getListByActivityId(WqActivityUser wqActivityUser){
        TableDataInfo info = wqActivityUserService.getPageListByActivityId(wqActivityUser);
        return info;
    }

    /**
     * 导出活动报名列表
     */
    @PreAuthorize("@ss.hasPermi('wq:activityUser:export')")
    @Log(title = "活动报名", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WqActivityUser wqActivityUser)
    {
        List<WqActivityUser> list = wqActivityUserService.selectWqActivityUserList(wqActivityUser);
        ExcelUtil<WqActivityUser> util = new ExcelUtil<WqActivityUser>(WqActivityUser.class);
        util.exportExcel(response, list, "活动报名数据");
    }

    /**
     * 获取活动报名详细信息
     */
    @PreAuthorize("@ss.hasPermi('wq:activityUser:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(wqActivityUserService.selectWqActivityUserById(id));
    }

    /**
     * 新增活动报名
     */
    @PreAuthorize("@ss.hasPermi('wq:activityUser:add')")
    @Log(title = "活动报名", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WqActivityUser wqActivityUser)
    {
        return toAjax(wqActivityUserService.insertWqActivityUser(wqActivityUser));
    }

    /**
     * 修改活动报名
     */
    @PreAuthorize("@ss.hasPermi('wq:activityUser:edit')")
    @Log(title = "活动报名", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WqActivityUser wqActivityUser)
    {
        return toAjax(wqActivityUserService.updateWqActivityUser(wqActivityUser));
    }

    /**
     * 删除活动报名
     */
    @PreAuthorize("@ss.hasPermi('wq:activityUser:remove')")
    @Log(title = "活动报名", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(wqActivityUserService.deleteWqActivityUserByIds(ids));
    }
}
